﻿@model IEnumerable<TweetsTranslate.Models.TweetModel>

@{
    ViewBag.Title = "Tweets Translate";
}

<h1>Tweets Translate</h1>
<br />
<p>
    Here you are able to search for the most recent tweets written in a specific language and translate them in another language.
    You can search by <b>screen name</b> OR by <b>keywords</b>. <br />
    To make a search you will have to provide a valid answer to the CAPTCHA question. To translate the tweets CAPTCHA is not needed.
</p>
<p>
    To view more details about the services used and implementation please check the <a href="/Home/About"><b>About</b></a> section.
</p>
<br/>
<div id="sides">

    <div id="left">
        <div class="form-horizontal">
            @using (Html.BeginForm("", "Home", FormMethod.Post))
            {
                <div class="form-group">
                    <label for="inputUserId" class="col-md-4 control-label">Screen name</label>
                    <div class="col-md-7">
                        <input type="text" value="@Html.Raw(Session["inputUserId"])" class="form-control" name="inputUserId" id="inputUserId">
                        @Html.ValidationMessage("inputUserId")
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputTags" class="col-md-4 control-label">Keywords</label>
                    <div class="col-md-7">
                        <input type="text" value="@Html.Raw(Session["inputKeywords"])" class="form-control" name="inputKeywords" id="inputTags">
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputNoTweets" class="col-md-4 control-label">Number of results</label>
                    <div class="col-md-7">
                        <input type="number" value="@Html.Raw(Session["noResults"])" class="form-control" name="inputNoTweets" id="noResults">
                    </div>
                </div>
                <div class="form-group">
                    <label for="languageListTranslateFrom" class="col-md-4 control-label">Search language</label>
                    <div class="col-md-7">
                        @Html.DropDownList("languageListTranslateFrom", (IEnumerable<SelectListItem>)Session["languageListFrom"], new { @class = "form-control" })
                    </div>
                </div>
                <div class="form-group">
                    <label for="languageListTranslateTo" class="col-md-4 control-label">Translate language</label>
                    <div class="col-md-7">
                        @Html.DropDownList("languageListTranslateTo", (IEnumerable<SelectListItem>)Session["languageListTo"], new { @class = "form-control" })
                    </div>
                </div>

                <div class="form-group">
                    <label for="captchaQuestion" class="col-md-4 control-label">CAPTCHA question</label>
                    <div class="col-md-7">
                        <p>
                            @Html.Raw(Session["captchaQuestion"])
                        </p>
                    </div>
                </div>

                <div class="form-group">
                    <label for="captchaAnswer" class="col-md-4 control-label">CAPTCHA answer</label>
                    <div class="col-md-7">
                        <input type="text" value="" class="form-control" name="captchaAnswer" id="captchaAnswer">
                        @Html.ValidationMessage("captchaAnswer")
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-4">
                        <button id="search_button" name="action:SearchTweets" class="btn btn-primary btn-large" type="submit">Search tweets</button>
                    </div>

                    <div class="col-md-6">
                        <button id="translate_button" name="action:TranslateTweets" class="btn btn-primary btn-large" type="submit">Translate tweets</button>
                    </div>
                </div>
            }
        </div>
    </div>
    <div id="right">
        <div class="panel panel-primary">
            <div class="panel-heading  panel-primary">
                Tweets
            </div>
            <div class="list-group" id="listGroupTweets">

                @foreach (var item in Model)
                {
                    <a class="list-group-item" href="@Html.DisplayFor(modelItem => item.Url)" target="_blank">

                        <div class="list-group-item-heading">
                            <b> Author: </b> @Html.DisplayFor(modelItem => item.Author)
                            <b> Date: </b> @Html.DisplayFor(modelItem => item.Date)
                        </div>

                        <p>
                            <b>Original:</b> @Html.DisplayFor(modelItem => item.OriginalText)
                        </p>
                        @if (item.TranslatedText.Length > 0)
                        {
                            <p>
                                <b> Translated: </b> @Html.DisplayFor(modelItem => item.TranslatedText)
                            </p>
                        }
                    </a>
                }
            </div>
        </div>
    </div>
</div>
